function trim(s) {
	if (s) {
		return s.replace(/^\s*|\s*$/g,"");
	}
	return null;
}
var RegisterForm = {
	initialize : function() {
		if ($('registerForm'))
			$('registerForm').onsubmit = RegisterForm.submit;
	},

	submit : function() {
		//alert("your trying to submit");
		var inputs = $A(document.getElementsByTagName("input"));
		var msg = "";
		var radioChecks = $H();
		inputs.each( function(e) {
			var value = e.value ? trim(e.value) : null;
			if (e.type == "text" && e.title && !value && e.className == "r") {
				msg += "\n " + e.title;
			}
			if ((e.type == "radio" || e.type == "checkbox") && e.className == "r") {
				var name = e.name;
				if (e.type == "checkbox") name = name.substr(0, name.lastIndexOf("-"));
				if (e.checked == false && ((!radioChecks[name]) || (radioChecks[name] && radioChecks[name] != 1))) {
					radioChecks[name] = e;
				} else {
					radioChecks[name] = 1;
				}
			}
		});
		radioChecks.each( function(e) {
			if (typeof(e) == "object" && e.value != 1) {
				msg += "\n " + e.value.title;
			}
		});
		if (msg.length > 0) {
			msg = "The following fields need to be completed before you can submit.\n\n" + msg;
			alert(msg);
			return false;
		}
		return true;
	}
};
window.onload = RegisterForm.initialize;